<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.20"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Detail: pool/service_data_pool.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Detail
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.20 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_cb9e5f3fc2694b8444c3259f896ee527.html">pool</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">service_data_pool.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="service__data__pool_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160; </div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment">// #ifndef SERVICE_DATA_POOL_HPP</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment">// #define SERVICE_DATA_POOL_HPP</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160; </div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#pragma once</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160; </div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160; </div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;<span class="keyword">namespace </span>guild_service {</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160;<span class="keyword">namespace </span>detail {</div>
<div class="line"><a name="l00030"></a><span class="lineno">   30</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno"><a class="line" href="service__data__pool_8hpp.html#ab6ae0dd98e9dbbc584c17026da045197">   31</a></span>&#160;<span class="keyword">using</span> <a class="code" href="service__data__pool_8hpp.html#ab6ae0dd98e9dbbc584c17026da045197">pool_index_type</a> = std::size_t;  </div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160; </div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> T,</div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;          <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Elem, <span class="keyword">typename</span> Alloc = std::allocator&lt;Elem&gt;&gt;</div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;          <span class="keyword">class </span>Container = std::vector&gt;</div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="classguild__service_1_1detail_1_1service__data__pool.html">   40</a></span>&#160;<span class="keyword">class </span><a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html">service_data_pool</a> final {</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160; <span class="keyword">public</span>:</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;  <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html">service_data_pool</a>(<a class="code" href="service__data__pool_8hpp.html#ab6ae0dd98e9dbbc584c17026da045197">pool_index_type</a> <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#a725fd9e261c5d4bb77061a93e887452e">size</a> = 64) : m_data_list(<a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#a725fd9e261c5d4bb77061a93e887452e">size</a>) {}</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160; </div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;  ~<a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html">service_data_pool</a>() = <span class="keywordflow">default</span>;</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160; </div>
<div class="line"><a name="l00051"></a><span class="lineno"><a class="line" href="classguild__service_1_1detail_1_1service__data__pool.html#a607e27562155f682a44460ab1dfca668">   51</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#a607e27562155f682a44460ab1dfca668">push</a>(<span class="keyword">const</span> T &amp;value) { m_data_list.emplace_back(value); }</div>
<div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160; </div>
<div class="line"><a name="l00058"></a><span class="lineno"><a class="line" href="classguild__service_1_1detail_1_1service__data__pool.html#ac9916cee36fca7b6c7fb4bf00eee11f0">   58</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#ac9916cee36fca7b6c7fb4bf00eee11f0">push</a>(T &amp;&amp;value) {</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    m_data_list.emplace_back(std::forward&lt;T&gt;(value));</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  }</div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno"><a class="line" href="classguild__service_1_1detail_1_1service__data__pool.html#a91dbbca71425381bc1322d917e78c99a">   68</a></span>&#160;  <span class="keyword">inline</span> <span class="keyword">const</span> T &amp;<a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#a91dbbca71425381bc1322d917e78c99a">get</a>(<a class="code" href="service__data__pool_8hpp.html#ab6ae0dd98e9dbbc584c17026da045197">pool_index_type</a> index)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;    <span class="keywordflow">if</span> (index &gt;= m_data_list.size()) {</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;      <span class="comment">// return empty_data();</span></div>
<div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;      <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#aed6ec69b0a65c1373428544411410014">resize</a>(index * 2 + 1);</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    }</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160; </div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;    <span class="keywordflow">return</span> m_data_list[index];</div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;  }</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160; </div>
<div class="line"><a name="l00083"></a><span class="lineno"><a class="line" href="classguild__service_1_1detail_1_1service__data__pool.html#a35d7465ec0cede33b3e9a6738869c089">   83</a></span>&#160;  <span class="keyword">inline</span> T &amp;<a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#a35d7465ec0cede33b3e9a6738869c089">get</a>(<a class="code" href="service__data__pool_8hpp.html#ab6ae0dd98e9dbbc584c17026da045197">pool_index_type</a> index) {</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keywordflow">if</span> (index &gt;= m_data_list.size()) {</div>
<div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;      <span class="comment">// return empty_data();</span></div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;      <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#aed6ec69b0a65c1373428544411410014">resize</a>(index * 2 + 1);</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    }</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160; </div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    <span class="keywordflow">return</span> m_data_list[index];</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;  }</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160; </div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;  <span class="comment">// inline</span></div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;  <span class="comment">// T&amp; empty_data() {</span></div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;  <span class="comment">//     return m_empty_data;</span></div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;  <span class="comment">// }</span></div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160; </div>
<div class="line"><a name="l00109"></a><span class="lineno"><a class="line" href="classguild__service_1_1detail_1_1service__data__pool.html#a12eb8f251bbc31bc1dcf0410d37feeb5">  109</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#a12eb8f251bbc31bc1dcf0410d37feeb5">is_empty_data</a>(<span class="keyword">const</span> T &amp;data)<span class="keyword"> const </span>{</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;    <span class="comment">// return data == m_empty_data;</span></div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;  }</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160; </div>
<div class="line"><a name="l00122"></a><span class="lineno"><a class="line" href="classguild__service_1_1detail_1_1service__data__pool.html#a2b9747711ba71ae152e0773a09bd0213">  122</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#a2b9747711ba71ae152e0773a09bd0213">set</a>(<a class="code" href="service__data__pool_8hpp.html#ab6ae0dd98e9dbbc584c17026da045197">pool_index_type</a> index, <span class="keyword">const</span> T &amp;value) {</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160;    <span class="keywordflow">if</span> (index &gt;= <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#a725fd9e261c5d4bb77061a93e887452e">size</a>()) {</div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;      <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#aed6ec69b0a65c1373428544411410014">resize</a>(index * 2 + 1);</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    }</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160; </div>
<div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;    m_data_list[index] = value;</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160; </div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;  }</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160; </div>
<div class="line"><a name="l00137"></a><span class="lineno"><a class="line" href="classguild__service_1_1detail_1_1service__data__pool.html#a725fd9e261c5d4bb77061a93e887452e">  137</a></span>&#160;  <span class="keyword">inline</span> <a class="code" href="service__data__pool_8hpp.html#ab6ae0dd98e9dbbc584c17026da045197">pool_index_type</a> <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#a725fd9e261c5d4bb77061a93e887452e">size</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> m_data_list.size(); }</div>
<div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160; </div>
<div class="line"><a name="l00144"></a><span class="lineno"><a class="line" href="classguild__service_1_1detail_1_1service__data__pool.html#aed6ec69b0a65c1373428544411410014">  144</a></span>&#160;  <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classguild__service_1_1detail_1_1service__data__pool.html#aed6ec69b0a65c1373428544411410014">resize</a>(<a class="code" href="service__data__pool_8hpp.html#ab6ae0dd98e9dbbc584c17026da045197">pool_index_type</a> count) { m_data_list.resize(count); }</div>
<div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160; </div>
<div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160; <span class="keyword">private</span>:</div>
<div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;  Container&lt;T&gt; m_data_list;</div>
<div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;};</div>
<div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160; </div>
<div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;}  <span class="comment">// namespace detail</span></div>
<div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;}  <span class="comment">// namespace guild_service</span></div>
<div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160; </div>
<div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;<span class="comment">// #endif  // SERVICE_DATA_POOL_HPP</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aservice__data__pool_8hpp_html_ab6ae0dd98e9dbbc584c17026da045197"><div class="ttname"><a href="service__data__pool_8hpp.html#ab6ae0dd98e9dbbc584c17026da045197">guild_service::detail::pool_index_type</a></div><div class="ttdeci">std::size_t pool_index_type</div><div class="ttdoc">数据池索引下标类型</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:31</div></div>
<div class="ttc" id="aclassguild__service_1_1detail_1_1service__data__pool_html_aed6ec69b0a65c1373428544411410014"><div class="ttname"><a href="classguild__service_1_1detail_1_1service__data__pool.html#aed6ec69b0a65c1373428544411410014">guild_service::detail::service_data_pool::resize</a></div><div class="ttdeci">void resize(pool_index_type count)</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:144</div></div>
<div class="ttc" id="aclassguild__service_1_1detail_1_1service__data__pool_html_a12eb8f251bbc31bc1dcf0410d37feeb5"><div class="ttname"><a href="classguild__service_1_1detail_1_1service__data__pool.html#a12eb8f251bbc31bc1dcf0410d37feeb5">guild_service::detail::service_data_pool::is_empty_data</a></div><div class="ttdeci">bool is_empty_data(const T &amp;data) const</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:109</div></div>
<div class="ttc" id="aclassguild__service_1_1detail_1_1service__data__pool_html"><div class="ttname"><a href="classguild__service_1_1detail_1_1service__data__pool.html">guild_service::detail::service_data_pool</a></div><div class="ttdoc">服务数据池类</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:40</div></div>
<div class="ttc" id="aclassguild__service_1_1detail_1_1service__data__pool_html_a725fd9e261c5d4bb77061a93e887452e"><div class="ttname"><a href="classguild__service_1_1detail_1_1service__data__pool.html#a725fd9e261c5d4bb77061a93e887452e">guild_service::detail::service_data_pool::size</a></div><div class="ttdeci">pool_index_type size() const</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:137</div></div>
<div class="ttc" id="aclassguild__service_1_1detail_1_1service__data__pool_html_a91dbbca71425381bc1322d917e78c99a"><div class="ttname"><a href="classguild__service_1_1detail_1_1service__data__pool.html#a91dbbca71425381bc1322d917e78c99a">guild_service::detail::service_data_pool::get</a></div><div class="ttdeci">const T &amp; get(pool_index_type index) const</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:68</div></div>
<div class="ttc" id="aclassguild__service_1_1detail_1_1service__data__pool_html_a607e27562155f682a44460ab1dfca668"><div class="ttname"><a href="classguild__service_1_1detail_1_1service__data__pool.html#a607e27562155f682a44460ab1dfca668">guild_service::detail::service_data_pool::push</a></div><div class="ttdeci">void push(const T &amp;value)</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:51</div></div>
<div class="ttc" id="aclassguild__service_1_1detail_1_1service__data__pool_html_ac9916cee36fca7b6c7fb4bf00eee11f0"><div class="ttname"><a href="classguild__service_1_1detail_1_1service__data__pool.html#ac9916cee36fca7b6c7fb4bf00eee11f0">guild_service::detail::service_data_pool::push</a></div><div class="ttdeci">void push(T &amp;&amp;value)</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:58</div></div>
<div class="ttc" id="aclassguild__service_1_1detail_1_1service__data__pool_html_a2b9747711ba71ae152e0773a09bd0213"><div class="ttname"><a href="classguild__service_1_1detail_1_1service__data__pool.html#a2b9747711ba71ae152e0773a09bd0213">guild_service::detail::service_data_pool::set</a></div><div class="ttdeci">bool set(pool_index_type index, const T &amp;value)</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:122</div></div>
<div class="ttc" id="aclassguild__service_1_1detail_1_1service__data__pool_html_a35d7465ec0cede33b3e9a6738869c089"><div class="ttname"><a href="classguild__service_1_1detail_1_1service__data__pool.html#a35d7465ec0cede33b3e9a6738869c089">guild_service::detail::service_data_pool::get</a></div><div class="ttdeci">T &amp; get(pool_index_type index)</div><div class="ttdef"><b>Definition:</b> service_data_pool.hpp:83</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="http://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.8.20
</small></address>
</body>
</html>
